// 关键字高亮
const changeText = (result, key, val) => {
    if (val != "") {
        // console.log(result, key, val);
        let arr = val.split("");
        let old = [];
        arr.forEach((el) => {
            old.push(el);
        });

        let arrText = [];

        result.forEach((el, index) => {
            el[key].split("").forEach((el1) => {
                arr.forEach((val) => {
                    if (val.indexOf(el1) !== -1) {
                        el[key] = el[key].replace(
                            new RegExp(el1, "g"),
                            `<span style=color:red>${el1}</span>`
                        );
                    }
                });
            });
        });
        return result;
    }
}

// 正则匹配html标签
const matcheHTML = (val) => {
    return val.replace(/<\/?.+?>/g, ""); // 去除html标签
}


// 导出
module.exports = {
    changeText,
    matcheHTML
}